const dict = require("../service/dict");
const ApiResult = require("../common/ApiResult");
const Enum = require("../enum");

module.exports = {
  getChildListByParentCode: async function(ctx) {
    const { parentCode } = ctx.params;
    if (!parentCode) {
      ctx.body = ApiResult.ERROR(Enum.PARAM_ERROR);
      return;
    }
    const rep = await dict.selectByParentCode(parentCode);
    if ("data" in rep) {
      ctx.body = ApiResult.SUCCESS(rep.data);
      return;
    }
    ctx.body = ApiResult.ERROR(rep.message);
  }
};
